package com.databing.demo.basics

import android.os.Bundle
import android.view.View
import androidx.databinding.ObservableInt
import com.databing.demo.annotation.ClazzInfo
import com.databing.demo.base.TitleActivity
import com.databing.demo.basics.data.ObservableFieldProfile
import com.databing.demo.databinding.ActivityObservableFieldBinding

/**
 * 创建日期：2020/11/2
 * 描述:这个Activity通过静态数据 增加赞的数据，查看更好的实现【ViewModelActivity】
 * 作者:支豪亮
 */
@ClazzInfo(1, 1, "第一小节", "通过静态数据 增加赞的数据")
class ObservableFieldActivity : TitleActivity() {

    private val data = ObservableFieldProfile("王五", 33, ObservableInt(0))

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val binding = ActivityObservableFieldBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.data = data
    }

    fun onLike(view: View) {
        data.like.set(data.like.get() + 1)
        data.name = "李四"
    }
}